package xdu.lz.stage3_classloader.chapter3;



import java.util.Arrays;

public class SimpleEncrypt {

    final static String str = "hello word";

    //加密因子
    private static final byte ENCRYPT_FACTOR = (byte) 0xff;

    public static void main(String[] args) {
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));
        byte[] encrypt = new byte[bytes.length];
        for (int i = 0; i < encrypt.length; i++) {
            encrypt[i] = (byte) (bytes[i] ^ ENCRYPT_FACTOR);
        }
        System.out.println("加密后:"+new String(encrypt));
        long l = System.nanoTime();
        byte[] decrypt = new byte[bytes.length];
        for (int i = 0; i < encrypt.length; i++) {
            decrypt[i] = (byte) (encrypt[i] ^ ENCRYPT_FACTOR);
        }
        System.out.println("解密后:"+new String(decrypt));
    }
}
